package com.gzx.asr.modular.text.mapper;

import com.gzx.asr.modular.text.entity.GzxAsrVoiceText;
import com.gzx.asr.modular.text.vo.GzxAsrVoiceTextVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import vip.xiaonuo.common.mapper.BaseMapperPlus;

import java.util.List;

/**
 * @author xbl
 */
@Mapper
public interface GzxAsrVoiceTextMapper extends BaseMapperPlus<GzxAsrVoiceText, GzxAsrVoiceTextVo> {

    //批量入库
    @Insert(value = {"<script>",
            "insert ignore into gzx_asr_voice_text(ht_voice_id,call_id,speaker_role,content,chat_time) " +
                    "values " +
                    "<foreach collection='list' item='asr' separator=','>" +
                    "(" +
                    "#{asr.htVoiceId}, " +
                    "#{asr.callId}, " +
                    "#{asr.speakerRole}, " +
                    "#{asr.content}, " +
                    "#{asr.chatTime} " +
                    ")" +
                    "</foreach>" +
                    "</script>"})
    void batchInsert(List<GzxAsrVoiceTextVo> textList);

    //每次获取上次处理之后的最大id
    @Select(value = {"<script>",
            "SELECT COALESCE(MAX(ht_voice_id), 0) FROM gzx_asr_voice_text",
            "</script>"})
    int getMaxVoiceId();
}
